home *** CD-ROM | disk | FTP | other *** search
/ Tiger Disk 11 / Tiger_Disk_011_19xx_Tiger-Crew-Disk_de_Side_B.d64 / 1541 alignment (.txt) next >
Commodore BASIC  |  2023-02-26  |  3KB  |  118 lines

  1. 10 rem  check/re-align a 1541
  2. 20 :
  3. 30 rem see prototype and instructions in
  4. 40 rem  g. neufeld's "1541 user's guide"  section 12.5
  5. 50 rem rewrite by dave walton
  6. 60 print"[147]    1541 alignment"
  7. 70 print" insert standard disk"
  8. 80 dim e$(16)
  9. 90 d=8:rem drive #
  10. 100 sid=54272:z$=chr$(0):dc$=z$+chr$(28)+chr$(1)
  11. 110 fori=sidtosid+23:pokei,0:next
  12. 120 pokei,15:pokesid+5,9
  13. 130 e$(0)="                       "
  14. 140 e$(1)="ok                     "
  15. 150 e$(2)="close to halfway       "
  16. 160 e$(3)="halfway (no data found)"
  17. 170 e$(9)="close to halfway       "
  18. 180 c$="":fori=1to11:read a:c$=c$+chr$(a):next
  19. 190 print" press any key to start"
  20. 200 geta$:ifa$="" then200
  21. 210 open 5,d,15
  22. 220 rem send machine code to drive
  23. 230 rem  (jump job runs in buf #0)
  24. 240 print#5,"m-w"z$chr$(3)chr$(11)c$
  25. 280 :
  26. 290 rem send "init disk" cmd to drive
  27. 300 print#5,"i":print"[147]":t=18
  28. 380 :
  29. 390 rem new track - show "??"
  30. 400 e=0
  31. 480 :
  32. 490 rem read the disk controller port
  33. 500 print#5,"m-r"dc$
  34. 510 get#5,a$:a=asc(a$+z$)
  35. 520 cv=3anda
  36. 530 a=(159anda)or(100+32*((t>17)+(t>24)+(t>30)))
  37. 540 print#5,"m-w"dc$chr$(a)
  38. 580 :
  39. 590 rem display values
  40. 600 t$=str$(tr):s$=str$(se):if e<>1 then t$="??":h1$="?":h2$="?":s$="??"
  41. 610 print"   align the 1541 drive"
  42. 620 print"track position:"t"[157]    "
  43. 630 print"track # read:  "right$(t$,2)
  44. 640 print"sector # read: "right$(s$,2)
  45. 650 print"disk id read:  "h1$;h2$
  46. 660 print"read results:"e$(e)
  47. 680 :
  48. 700 print"commands:"
  49. 710 print"  f1 = move head out (lower track #)
  50. 720 [153]"  f2 = move head to track 1
  51. 730 print"  f3 = move head in (higher track #)
  52. 740 [153]"  f4 = move head to track 35
  53. 750 print"  f5 = initialize (to track 18)"
  54. 760 print"  f7 = end program"
  55. 780 :
  56. 790 rem check keyboard
  57. 800 geta$:k=asc(a$+z$)-132
  58. 810 ifk>0then onkgoto1300,1320,300,1800,1340,1360
  59. 860 :
  60. 870 rem attempt to read any header
  61. 880 :
  62. 890 rem put jmp job in the job queue
  63. 900 print#5,"m-w"z$z$chr$(1)chr$(208)
  64. 980 :
  65. 990 rem check results
  66. 1000 print#5,"m-r"z$z$
  67. 1010 get#5,a$:e=asc(a$+z$)
  68. 1020 rem "e" is fdc error code returned
  69. 1030 ife=3 then fh=20:goto 1200
  70. 1040 ife=2 or e=9 then fh=30:goto1200
  71. 1050 ife<>1 then400
  72. 1080 :
  73. 1090 rem read ok; get id, track, sector
  74. 1100 print#5,"m-r"chr$(22)z$chr$(4)
  75. 1110 get#5,h1$,h2$,h3$,h4$
  76. 1120 tr=asc(h3$+z$)
  77. 1130 se=asc(h4$+z$)
  78. 1140 goto500
  79. 1180 :
  80. 1190 rem boing sound
  81. 1200 pokesid+4,0
  82. 1210 pokesid+1,fh
  83. 1220 pokesid+4,17
  84. 1230 goto500
  85. 1280 :
  86. 1290 rem move head in or out
  87. 1300 ift>1 then1500
  88. 1310 goto900
  89. 1320 ift<40 then c=1:goto1510
  90. 1330 goto900
  91. 1340 ift>1 then c=-1:l=2*(t-1):goto1400
  92. 1350 goto900
  93. 1360 ift<35 then c=1:l=2*(35-t):goto1400
  94. 1370 ift=35 then900
  95. 1380 c=-1:l=2*(t-35)
  96. 1400 fori=1tol:gosub1600:next:goto400
  97. 1500 c=-1
  98. 1510 gosub1600:goto400
  99. 1580 :
  100. 1590 rem move head one half-track
  101. 1600 t=t+c*.5
  102. 1610 cv=(cv+c)and3:a=(252anda)+cv
  103. 1620 print#5,"m-w"dc$chr$(a):return
  104. 1780 :
  105. 1790 rem end program (turn drive off)
  106. 1800 print#5,"m-w"dc$chr$(240)
  107. 1810 fori=sid tosid+23:pokei,0:next
  108. 1820 forj=1to100:nextj:pokei,0
  109. 1830 close5:end
  110. 2000 :
  111. 2010 rem  machine code routine to read a header
  112. 2020 rem  resides at $0300 (buffer #0)
  113. 2030 data 169,48:    :rem lda #$30
  114. 2040 data 133,69:    :rem sta $45
  115. 2050 data 169,00:    :rem lda #$00
  116. 2060 data 133,63:    :rem sta $3f
  117. 2070 data 76,177,243 :rem jmp $f3b1
  118.